/*
 * pnlPurchase.java
 *
 * Created on December 26, 2009, 1:19 AM
 */

package demogroup5client.ui;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 *
 * @author  Administrator
 */
public class Home extends javax.swing.JPanel {

    Timer timer = new Timer();
    /** Creates new form pnlPurchase */
    public Home() {
        initComponents();
        timer.schedule(new clock(), 0, 1*1000);
    }

    static class clock extends TimerTask{
        @Override
        public void run() {
            Calendar now = Calendar.getInstance();
            StringBuilder strB = new StringBuilder();
            String str1;
            if(now.get(Calendar.SECOND)<10){
                str1 = "0" + Integer.toString(now.get(Calendar.SECOND)) ;
            }else{
                str1 = Integer.toString( now.get(Calendar.SECOND)) ;
            }
            String str2 ;
            if(now.get(Calendar.MINUTE)<10){
                str2 = "0" + Integer.toString(now.get(Calendar.MINUTE)) + " : ";
            }else{
                str2 = Integer.toString( now.get(Calendar.MINUTE)) + " : ";
            }

            String str3;
            if(now.get(Calendar.HOUR)<10){
                str3 = "0" + Integer.toString(now.get(Calendar.HOUR)) + " : ";
            }else{
                str3 = Integer.toString( now.get(Calendar.HOUR)) + " : ";
            }

            strB.append(str3);
            strB.append(str2);
            strB.append(str1);

            jTextField2.setText(strB.toString());
            // dd/MM/yyyy
            StringBuilder strD = new StringBuilder();
            String strD1;
            if(now.get(Calendar.DATE)<10){
                strD1 = "0" + Integer.toString(now.get(Calendar.DATE)) + " - ";
            }else{
                strD1 = Integer.toString( now.get(Calendar.DATE)) + " - ";
            }
            String strD2 ;
            if(now.get(Calendar.MONTH)<10){
                strD2 = "0" + Integer.toString(now.get(Calendar.MONTH)+1) + " - ";
            }else{
                strD2 = Integer.toString( now.get(Calendar.MONTH)+1) + " - ";
            }
            String strD3 = Integer.toString( now.get(Calendar.YEAR));
            
            strD.append(strD1);
            strD.append(strD2);
            strD.append(strD3);
            jTextField1.setText(strD.toString());

            ///////////
//            date = new Date();
//            StringBuilder strB = new StringBuilder();
//            String str1;
//            if(date.getSeconds()<10){
//                str1 = "0" + Integer.toString(date.getSeconds()) ;
//            }else{
//                str1 = Integer.toString( date.getSeconds()) ;
//            }
//
//            String str2 = Integer.toString( date.getMinutes()) + " : ";
//            String str3 = Integer.toString( date.getHours()) + " : ";
//            strB.append(str3);
//            strB.append(str2);
//            strB.append(str1);
//
//            jTextField2.setText(strB.toString());
//            // dd/MM/yyyy
//            StringBuilder strD = new StringBuilder();
//            String strD1;
//            if(date.getDate()<10){
//                strD1 = "0"+Integer.toString(date.getDate())+" - ";
//            }else{
//                strD1 = Integer.toString(date.getDate())+" - ";
//            }
//            String strD2 = Integer.toString(date.getMonth()+1)+" - ";
//
//            String strD3 = Integer.toString(date.getYear());
//
//            strD.append(strD1);
//            strD.append(strD2);
//            strD.append(strD3);
//            jTextField1.setText(strD.toString());
        }
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jTextField2 = new javax.swing.JTextField();

        setPreferredSize(new java.awt.Dimension(820, 510));
        setLayout(null);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Top Customer"));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 614, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 200, Short.MAX_VALUE)
        );

        add(jPanel1);
        jPanel1.setBounds(10, 10, 630, 230);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Top Customer"));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 614, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 220, Short.MAX_VALUE)
        );

        add(jPanel2);
        jPanel2.setBounds(10, 250, 630, 250);

        jTextField1.setBackground(new java.awt.Color(204, 255, 204));
        jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTextField1.setEnabled(false);
        add(jTextField1);
        jTextField1.setBounds(660, 20, 150, 20);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("About"));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 154, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 390, Short.MAX_VALUE)
        );

        add(jPanel3);
        jPanel3.setBounds(650, 80, 170, 420);

        jTextField2.setBackground(new java.awt.Color(204, 255, 204));
        jTextField2.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTextField2.setEnabled(false);
        add(jTextField2);
        jTextField2.setBounds(740, 50, 70, 20);
    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private static javax.swing.JTextField jTextField1;
    private static javax.swing.JTextField jTextField2;
    // End of variables declaration//GEN-END:variables
    
}
